package com.geek.video.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 解析方式枚举
 *
 * @author Steven
 */
public enum WayEnum {

    /**
     * '解析方式 0 - json格式 1 - 爬虫解析
     */
    JSON(0, "json格式"),

    CRAWLER(1, "爬虫解析"),
    ;

    private int code;

    private String message;

    WayEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * 通过枚举值获取枚举
     */
    private static final Map<Integer, WayEnum> COLLECT = Arrays.stream(
            WayEnum.values()).collect(Collectors.toMap(WayEnum::getCode, Function.identity()));

    public static WayEnum getWayEnumByCode(Integer code) {

        return COLLECT.get(code);
    }
}
